<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<!DOCTYPE html>
<html lang="zh-cn">
<c:set var="text" value="添加"/>
<c:if test="${permission.id>0}">
    <c:set var="text" value="修改"/>
</c:if>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>${text}权限信息</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/front/css/bootstrap.min.css"/>
</head>
<body>
<%@include file="/inc/menu.jsp"%>
<nav class="permission-nav">
    <div class="container-fluid">
        <div class="main-content">
            <div class="row">
                <div class="col-sm-12">
                    <ul class="nav nav-tabs nav-3rd">
                        <li><span>权限管理</span></li>
                        <li><a href="${pageContext.request.contextPath}/admin/permission/list">权限列表</a></li>
                        <li class="active">${text}权限信息</li>
                    </ul>
                </div>
            </div>
            <div class="inner-content inner-content-left">
                <form id="editForm" class="material-edit" name="permission"
                      action="${pageContext.request.contextPath}/admin/permission/edit"
                      method="post">
                    <div class="hidden">
                        <input type="hidden" name="id" value="${resoPerm.id}"/><br/>
                        <input type="hidden" name="oldResoPermString" value="${resoPerm.resoPermString}"/>
                    </div>
                    <div class="form-group">
                        <label>权限键值(唯一)<span class="required">*</span></label>

                        <div>
                            <input class="form-control" type="text" name="resoPermString" value="${resoPerm.resoPermString}" autofocus
                                   required/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>权限中文名<span class="required">*</span></label>

                        <div>
                            <input class="form-control" type="text" name="cnName" value="${resoPerm.cnName}"
                                   required/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>资源<span class="required">*</span></label>
                        <div>
                            <div class="input-group">
                                <select class="form-control" name="resourceId">
                                    <c:forEach items="${canGetPermission}" var="resource">
                                        <option value="${resource.id}"
                                                <c:if test="${resoPerm.resource.id == resource.id}">
                                                    selected
                                                </c:if>
                                                >${resource.cnName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>权限<span class="required">*</span></label>
                        <div>
                            <div class="input-group">
                                <select class="form-control" name="permissionId">
                                    <c:forEach items="${permissionList}" var="permission">
                                        <option value="${permission.id}"
                                                <c:if test="${resoPerm.permission.id == permission.id}">
                                                    selected
                                                </c:if>
                                                >${permission.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <button class="btn btn-lg btn-block btn-primary">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</nav>

</body>
</html>
